<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('系统管理员操作界面')"/>
    <!--<th:block th:include="include :: bootstrap-select-css"/>-->
    <!--<th:block th:include="include :: jasny-bootstrap-css"/>-->
    <!--<th:block th:include="include :: datetimepicker-css"/>-->
    <link th:href="@{/ruoyi/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/ruoyi/css/jquery-confirm.min.css}" rel="stylesheet"/>
</head>
<style type="text/css">
    .table {
        table-layout: fixed;
    }

    #macdz_id {
        width: 200px;
        height: 32px;
        border: none;
        border-bottom: 1px solid #e5e6e7;
    }

    #macdz_id > input {
        height: 21px;
        width: 26.3px;
        border: none;
        text-align: center;
    }

    #macdz_id > input[readonly] {
        background-color: #EEEEEE;
    }

    #ipdz_id {
        width: 200px;
        height: 32px;
        border: none;
        border-bottom: 1px solid #e5e6e7;
    }

    #ipdz_id > input {
        height: 21px;
        width: 32.3px;
        border: none;
        text-align: center;
    }

    #ipdz_id > input[readonly] {
        background-color: #EEEEEE;
    }
</style>
<body class="gray-bg">
<!--生成二维码开始-->
<div class="modal fade" id="empAddModal" tabindex="-1" role="dialog" aria-hidden="true"
     data-keyboard="false">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">生成设备二维码</h4>
            </div>
            <div class="modal-body">
                <form id="form-user-add" class="form-horizontal">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <input name="went" disabled id="text" class="form-control" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <div class="ibox-content no-padding">
                                    <div class="edittosummernote" id="qrcode"
                                         style="width:100px; height:100px; margin-top:15px;">
                                    </div>
                                    <input name="qrcode" id="qrcode_update_input_15" class="form-control" type="hidden">
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer" style="margin-top: -30px">
                <button type="button" class="btn btn-white" data-dismiss="modal" style="margin-top: -5px">关闭</button>
                <button type="button" class="btn btn-white" id="emp_save_btn" onclick="updatespkfk(this)"
                        style="margin-top: -5px">保存
                </button>
            </div>
        </div>
    </div>
</div>
<!--生成二维码结束-->
<!--添加模态框开始-->
<div class="modal fade" id="sbAddModal" tabindex="-1" role="dialog" aria-hidden="true"
     data-keyboard="false">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h1 class="modal-title"><strong>添加设备</strong></h1>
            </div>
            <div class="modal-body">
                <form id="form-sb-add" class="form-horizontal">
                    <div class="row" style="margin-top: -30px;margin-left: -65px">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" style="margin-left:-10px">设备类型</label>
                            <div class="col-sm-2" style="margin-left:-20px;width: 160px">
                                <select name="sbbh_sel" id="sbbh_sel" class="form-control"
                                        style="border: none;border-bottom: 1px solid #e5e6e7;">
                                    <option value="GASB-082-">台式电脑</option>
                                    <option value="GASB-085-">针式打印机</option>
                                    <option value="GASB-084-">激光打印机</option>
                                    <option value="GASB-089-">笔记本电脑</option>
                                    <option value="GASB-083-">喷墨打印机</option>
                                    <option value="GASB-086-">网关设备</option>
                                    <option value="GASB-087-">投影仪</option>
                                    <option value="GASB-088-">服务器</option>
                                </select>
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-85px">设备名称</label>
                            <div class="col-sm-2" style="margin-left:-20px;width: 190px">
                                <input name="sbmc" id="sbmc_id" class="form-control" type="text" placeholder="请输入设备名称"
                                       readonly="readonly"
                                       style="border: none;border-bottom: 1px solid #e5e6e7;background-color: #fff">
                                <input type="hidden" id="sbmc_option">
                                <input type="hidden" id="sbmc_index">
                            </div>
                            <div class="col-sm-2" style="margin-left: -20px;width: 190px;">
                                <input name="sbbh" placeholder="请点击生成设备编号" id="sbbh_id" class="form-control" type="text"
                                       style="border: none;border-bottom: 1px solid #e5e6e7;" required="required"></div>
                            <div class="col-sm-1"><img src="/img/700.gif" style="margin-left: -25px;width: 200%"></div>
                            <div class="col-sm-1" style="margin-left: -15px">
                                <a class="btn btn-primary btn-rounded btn-sm" id="creat_sbbh_btn">
                                    <i class="fa fa-search"></i>生成设备编号</a>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-left: -65px;margin-top: -10px">
                        <div class="form-group">

                            <label class="col-sm-2 control-label" style="margin-left:-10px">品牌型号</label>
                            <div class="col-sm-2" style="margin-left:-20px;width: 220px">
                                <input name="guige" id="guige_id" class="form-control" type="text" placeholder="请输入品牌型号"
                                       style="border: none;border-bottom: 1px solid #e5e6e7" required="required">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">生产厂家</label>
                            <div class="col-sm-2" style="margin-left:-20px;width: 220px">
                                <input name="shccj" id="shccj_id" class="form-control" type="text" placeholder="请输入生产厂家"
                                       style="border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">使用部门</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 145px">
                                <div class="input-group">
                                    <select name="bmid" class="form-control m-b" id="bmid_id"
                                            style="border: none;border-bottom: 1px solid #e5e6e7;">
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-1">
                                <div class="input-group">
                                    <input name="shiyr" id="shiyr_id" class="form-control" list="browsers"
                                           placeholder="姓名拼音"
                                           style="border: none;border-bottom: 1px solid #e5e6e7;margin-left:-35px;width: 80px">
                                    <datalist id="browsers"></datalist>
                                    <span class="help-block"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-left: -65px">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" style="margin-left:-10px">主板型号</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 220px">
                                <input name="zbxh" id="zbxh_id" class="form-control" type="text" placeholder="请输入主板型号"
                                       style="border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">CPU型号</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 220px">
                                <input name="cpuxh" id="cpuxh_id" class="form-control" type="text"
                                       placeholder="请输入CPU型号" style="border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">购买日期</label>
                            <div class="col-sm-2 input-group date" style="margin-left:-20px;width: 190px">
                                <span class="input-group-addon"
                                      style="border: none;border-bottom: 1px solid #e5e6e7;"><i
                                        class="fa fa-calendar"></i></span>
                                <input name="gmrq" id="gmrq_id" class="form-control" type="text" readonly="readonly"
                                       placeholder="yyyy-MM-dd"
                                       style="background-color: #FFFFFF; border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-left: -65px">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" style="margin-left:-10px">显示器品牌尺寸</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 220px">
                                <input name="xsqppcc" id="xsqppcc_id" class="form-control" type="text"
                                       placeholder="请输入显示器品牌与尺寸" style="border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">内存大小</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 220px">
                                <input name="ncggdx" id="ncggdx_id" class="form-control" type="text"
                                       placeholder="请输入内存大小" style="border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">硬盘信息</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 150px;">
                                <input name="ypdx" id="ypdx_id_1" class="form-control" type="text"
                                       placeholder="请点击硬盘一按钮     "
                                       style="border: none;border-bottom: 1px solid #e5e6e7;text-align:right;padding-right: 3px;padding-left: 3px">
                            </div>
                            <div class="col-sm-1" style="margin-left:-20px">
                                <a class="btn btn-rounded btn-sm" id="ypdx_btn_1"
                                   style="width: 60px; background-color: #8EE5EE; color: #ffffff; text-align: center;padding-left: 8px; display:inline-block">硬盘一</a>
                            </div>

                        </div>
                    </div>
                    <div class="row" style="margin-left: -65px">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"
                                   style="margin-left:-10px">IP&nbsp&nbsp;地&nbsp;&nbsp;址</label>
                            <div class="col-sm-1" id="ipdz_id" style="margin-left:-5px;width: 190px">
                                <input type="text" value="" id="ipdz1" class="ip1" maxlength="3">.<input
                                    type="text" value="" id="ipdz2" class="ip2" maxlength="3">.<input
                                    type="text" value="" id="ipdz3" class="ip3" maxlength="3">.<input
                                    type="text" value="" id="ipdz4" class="ip4" maxlength="3">
                            </div>
                            <input type="hidden" name="ipdz" id="ip">
                            <label class="col-sm-2 control-label" style="margin-left:-65px">MAC地址</label>
                            <div class="col-sm-1" id="macdz_id"
                                 style="margin-left:-5px;width: 190px;padding-left: 0px;padding-right: 0px">
                                <input type="text" value="" class="mac1" maxlength="2" style="width: 25px">-
                                <input type="text" value="" class="mac2" maxlength="2" style="width: 25px">-
                                <input type="text" value="" class="mac3" maxlength="2" style="width: 25px">-
                                <input type="text" value="" class="mac4" maxlength="2" style="width: 25px">-
                                <input type="text" value="" class="mac5" maxlength="2" style="width: 25px">-
                                <input type="text" value="" class="mac6" maxlength="2" style="width: 25px">
                            </div>
                            <input type="hidden" name="macdz" id="mac">
                            <label class="col-sm-2 control-label" style="margin-left:-65px">硬盘大小</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 150px;">
                                <input name="ypdx" id="ypdx_id_2" class="form-control" type="text"
                                       placeholder="请点击硬盘二按钮     "
                                       style="border: none;border-bottom: 1px solid #e5e6e7;text-align:right;padding-right: 3px;padding-left: 3px">
                            </div>
                            <div class="col-sm-1" style="margin-left:-20px">
                                <a class="btn btn-rounded btn-sm" id="ypdx_btn_2"
                                   style="width: 60px; background-color: #8EE5EE; color: #ffffff; text-align: center;padding-left: 8px; display:inline-block">硬盘二</a>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-left: -65px">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" style="margin-left:-10px">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</label>
                            <div class="col-sm-10" style="margin-left:-20px;width: 490px">
                                <input name="beiz" id="beiz_id" class="form-control" type="text" placeholder="请输入备注"
                                       style="border: none;border-bottom: 1px solid #e5e6e7;">
                            </div>
                            <label class="col-sm-2 control-label" style="margin-left:-80px">硬盘大小</label>
                            <div class="col-sm-1" style="margin-left:-20px;width: 150px;">
                                <input name="ypdx" id="ypdx_id_3" class="form-control" type="text"
                                       placeholder="请点击硬盘三按钮     "
                                       style="border: none;border-bottom: 1px solid #e5e6e7;text-align:right;padding-right: 3px;padding-left: 3px">
                            </div>
                            <div class="col-sm-1" style="margin-left:-20px">
                                <a class="btn btn-rounded btn-sm" id="ypdx_btn_3"
                                   style="width: 60px; background-color: #8EE5EE; color: #ffffff; text-align: center;padding-left: 8px; display:inline-block">硬盘三</a>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <div class="modal-footer" style="height:0px">
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-white" id="sb_save_btn" onclick="savesb()">保存
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--添加模态框结束-->
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="operlog-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>检索：</label><input type="text" name="sbbh" id="sbbh" placeholder="请输入设备编码进行查询"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" id="search_btn"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="gettjmtk()">
                <i class="fa fa-pencil"></i> 添加设备
            </a>
            <a class="btn btn-danger" onclick="Mysbtz()" id="remove">
                <i class="fa fa-remove"></i> 设备台账打印
            </a>
            <a class="btn btn-info" onclick="MyPreview()" id="print">
                <i class="fa fa-remove"></i> 二维码打印
            </a>
            <div class="col-sm-4" style="margin-left:-20px;width: 250px">
                <select name="sbmc_sel" id="sbmc_sel" class="form-control">
                    <option value="GASB-">请选择打印设备名称</option>
                    <option value="GASB-082-">台式电脑</option>
                    <option value="GASB-085-">针式打印机</option>
                    <option value="GASB-084-">激光打印机</option>
                    <option value="GASB-089-">笔记本电脑</option>
                    <option value="GASB-083-">喷墨打印机</option>
                    <option value="GASB-086-">网关设备</option>
                    <option value="GASB-087-">投影仪</option>
                    <option value="GASB-088-">服务器</option>
                </select>
            </div>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
        <!--隐藏的打印设备标签二维码表格开始-->
        <div class="col-sm-12 select-table table-striped" id="divid" style="display: none">
        </div>
        <!--隐藏的打印设备标签二维码表格结束-->
        <!--隐藏的打印设备台账表格开始-->
        <div class="col-sm-12 select-table table-striped" id="divid_sbtz" style="display: none">
            <table class='table table-hover table-bordered' cellpadding='0' border='1' cellspacing='0'
                   id="tableid_sbtz">
                <thead>
                <div><p>计算机设施设备管理台帐</p></div>
                <tr style="font-size: 9pt;font-family: 微软雅黑;">
                    <td align="center" style="background-color: #99CCFF">序号</td>
                    <td align="center" style="background-color: #99CCFF">设备编号</td>
                    <td align="center" style="background-color: #99CCFF">设备名称</td>
                    <td align="center" style="background-color: #99CCFF">主板</td>
                    <td align="center" style="background-color: #99CCFF">CPU</td>
                    <td align="center" style="background-color: #99CCFF">内存</td>
                    <td align="center" style="background-color: #99CCFF">硬盘</td>
                    <td align="center" style="background-color: #99CCFF">显示器</td>
                    <td align="center" style="background-color: #99CCFF">单位</td>
                    <td align="center" style="background-color: #99CCFF">数量</td>
                    <td align="center" style="background-color: #99CCFF">生产厂商</td>
                    <td align="center" style="background-color: #99CCFF">购置日期</td>
                    <td align="center" style="background-color: #99CCFF">IP</td>
                    <td align="center" style="background-color: #99CCFF">MAC</td>
                    <td align="center" style="background-color: #99CCFF">备注</td>
                    <td align="center" style="background-color: #99CCFF">部门</td>
                    <td align="center" style="background-color: #99CCFF">签字</td>
                </tr>
                </thead>
                <tbody id="tbody_id">
                </tbody>
            </table>
        </div>
        <!--隐藏的打印设备台账表格结束-->
    </div>
</div>
<th:block th:include="include :: footer"/>
<!--<th:block th:include="include :: bootstrap-select-js"/>-->
<!--<th:block th:include="include :: jasny-bootstrap-js"/>-->
<!--<th:block th:include="include :: datetimepicker-js"/>-->
<!--<script th:src="@{/ruoyi/js/jquery.cookie.js}"></script>-->
<script th:src="@{/ruoyi/js/jquery-confirm.min.js}"></script>
<script th:src="@{/ruoyi/js/jquery.form.js}"></script>
<script th:inline="javascript">
    var selections = [];
    var LODOP; //声明为全局变量
    var now = getNow();
    watermark({"watermark_txt": "海 王 国 安" + now});
    //打开网页加载bootstrap-table数据
    $(document).ready(function () {
        initUserTable();
        function initUserTable() {
            $("#bootstrap-table").bootstrapTable({
                toolbar: '#toolbar',
                showToggle: true,//是否切换显示
                showColumns: true,//是否显示列，
                showColumnsToggleAll: true,
                detailView: true,//和下面的属性成对设置，是否显示加号显示详细信息
                detailFormatter: "detailFormatter",
                showExport: true,//是否导出
                // showPaginationSwitch: true,//切换是否分页显示
                showFooter: true,//是否显示页脚，主要用途是显示汇总的信息
                striped: false,//是否显示行间隔色
                paginationPreText: '上一页',
                paginationNextText: '下一页',
                queryParamsType: '',
                method: 'GET',
                uniqueId: "id",
                exportDataType: "basic", //basic', 'all', 'selected'.
                // exportTypes:['Excel'],  //导出文件类型
                pageNumber: 1,
                pagination: true,//是否分页
                sidePagination: 'server',//server:服务器端分页|client：前端分页
                pageSize: 10,//单页记录数
                pageList: [10, 20, 30, 'ALL'],//可选择单页记录数
                showRefresh: true,//刷新按钮
                queryParams: queryParams,
                // onDblClickRow: function (row,index) {
                //     console.log(index[0])
                // },
                onDblClickRow: function (row, tr, flied) {
                    tr.addClass("selected")
                    alert(row.id)
                    tr.attr("checked", true)
                },

                url: "/nc/sbxxb/getsball/",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'no',
                        title: '序号',
                        align: "center",
                        width: 60,
                        formatter: function (value, row, index) {
                            //获取每页显示的数量
                            var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                            //获取当前是第几页
                            var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                            //返回序号，注意index是从0开始的，所以要加上1
                            return pageSize * (pageNumber - 1) + index + 1;
                        }
                    },
                    {
                        field: 'sbbh',
                        title: '设备编码'
                    },
                    {
                        field: 'sbmc',
                        title: '设备名称'
                    },
                    {
                        field: 'guige',
                        title: '规格型号',
                        // sortable: true,
                    },
                    {
                        field: 'bmid',
                        title: '设备部门id号'
                    },
                    {
                        field: 'shiyr',
                        title: '设备使用人'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            // var actions = [];
                            // actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="updatetjmtk(row.id)" data-toggle="modal" data-target="#myModal5"><i class="fa fa-edit"></i>编辑</a> ');
                            // actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            // // actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="resetPwd(\'' + row.userId + '\')"><i class="fa fa-key"></i>重置</a>');
                            // return actions.join('');
                            var id = index;
                            var data = JSON.stringify(row);
                            var result = "";
                            result += "<a href='javascript:;' class='btn btn-xs green' onclick=\"ViewById('" + id + "')\" title='查看'><span class='glyphicon glyphicon-search'></span></a>";
                            result += "<a href='javascript:;' class='btn btn-xs blue' onclick=\"EditViewById('" + row + "','" + id + "')\" title='生成二维码'><span class='glyphicon glyphicon-pencil'></span></a>";
                            result += "<a href='javascript:;' class='btn btn-xs red' onclick=\"DeleteByIds('" + id + "')\" title='删除'><span class='glyphicon glyphicon-remove'></span></a>";
                            return result;
                        }
                    }]
            })
        }
        //隐藏的table,显示按设备名称，生成
        var sbmc = $('#sbmc_sel option:selected').val()
        $.ajax({
            url: "/nc/sbxxb/getsbwh/" + sbmc,
            type: 'GET',
            success: function (data) {
                // $('#tableid_sbtz').empty();
                var tables = "";   //字符串拼接
                var j = 0;
                for (var i in data) {  //遍历json数组
                    j = parseInt(i) + 1;
                    tables = "<tr style='font-family: 微软雅黑;font-size: 9pt;height: 30px'>"
                        + "<td align='center'>" + j + "</td>"
                        + "<td align='center'>" + data[i].sbbh + "</td>"
                        + "<td align='center'>" + data[i].sbmc + "</td>"
                        + "<td align='center'>" + data[i].zbxh + "</td>"
                        + "<td align='center'>" + data[i].cpuxh + "</td>"
                        + "<td align='center'>" + data[i].ncggdx + "</td>"
                        + "<td align='center'>" + data[i].ypdx + "</td>"
                        + "<td align='center'>" + data[i].xsqppcc + "</td>"
                        + "<td align='center'>" + data[i].dw + "</td>"
                        + "<td align='center'>" + data[i].shul + "</td>"
                        + "<td align='center'>" + data[i].shccj + "</td>"
                        + "<td align='center'>" + data[i].gmrq + "</td>"
                        + "<td align='center'>" + data[i].ipdz + "</td>"
                        + "<td align='center'>" + data[i].macdz + "</td>"
                        + "<td align='center'>" + data[i].beiz + "</td>"
                        + "<td align='center'>" + data[i].bmid + "</td>"
                        + "<td align='center'>" + data[i].shiyr + "</td>"
                        + "</tr>";
                    $('#tableid_sbtz').append(tables);
                }
            }
        })
    });

    //查询按钮事件
    $('#search_btn').click(function () {
        $('#bootstrap-table').bootstrapTable('refresh', {
            url: '/nc/sbxxb/getsblist/' + $('#sbbh').val(),
        });
    });
//点击生成设备编号后的js
    $('#creat_sbbh_btn').click(function () {
        var sb = $("#sbbh_sel option:selected").val();
        var sbmc = $("#sbbh_sel option:selected").text();
        var sbbh = "";
        $.ajax({
            url: "/nc/sbxxb/maxsbbh/" + sb,
            type: 'GET',
            success: function (data) {
                sbbh = sb + (parseInt(data) + 1);
                $("#sbbh_id").val(sbbh);
                $("#sbmc_id").val(sbmc);
                $("#sbbh_id").attr("readOnly", "readOnly")
            },
        })
        if (sbmc.indexOf("电脑") < 0 && sbmc.indexOf("务器") < 0) {
            alert("你添加的设备不是电脑或服务器，背景颜色是灰色的不用填写")
            $("#zbxh_id").attr("readOnly", "readOnly")
            $("#cpuxh_id").attr("readOnly", "readOnly")
            $("#ncggdx_id").attr("readOnly", "readOnly")
            $("#xsqppcc_id").attr("readOnly", "readOnly")
            $('#ipdz1').attr("readOnly", "readOnly")
            $('#ipdz2').attr("readOnly", "readOnly")
            $('#ipdz3').attr("readOnly", "readOnly")
            $('#ipdz4').attr("readOnly", "readOnly")
            $('.mac1').attr("readOnly", "readOnly")
            $('.mac2').attr("readOnly", "readOnly")
            $('.mac3').attr("readOnly", "readOnly")
            $('.mac4').attr("readOnly", "readOnly")
            $('.mac5').attr("readOnly", "readOnly")
            $('.mac6').attr("readOnly", "readOnly")
            $("#ypdx_id_1").attr("readOnly", "readOnly")
            $("#ypdx_id_2").attr("readOnly", "readOnly")
            $("#ypdx_id_3").attr("readOnly", "readOnly")
            $('#ypdx_btn_1').attr("disabled", "disabled")
            $('#ypdx_btn_2').attr("disabled", "disabled")
            $('#ypdx_btn_3').attr("disabled", "disabled")
        } else {
            $("#zbxh_id").removeAttr("readOnly")
            $("#cpuxh_id").removeAttr("readOnly")
            $("#ncggdx_id").removeAttr("readOnly")
            $("#xsqppcc_id").removeAttr("readOnly")
            $('#ipdz1').removeAttr("readOnly")
            $('#ipdz2').removeAttr("readOnly")
            $('#ipdz3').removeAttr("readOnly")
            $('#ipdz4').removeAttr("readOnly")
            $('.mac1').removeAttr("readOnly")
            $('.mac2').removeAttr("readOnly")
            $('.mac3').removeAttr("readOnly")
            $('.mac4').removeAttr("readOnly")
            $('.mac5').removeAttr("readOnly")
            $('.mac6').removeAttr("readOnly")
            $("#ypdx_id_1").removeAttr("readOnly")
            $("#ypdx_id_2").removeAttr("readOnly")
            $("#ypdx_id_3").removeAttr("readOnly")
            $('#ypdx_btn_1').removeAttr("disabled")
            $('#ypdx_btn_2').removeAttr("disabled")
            $('#ypdx_btn_3').removeAttr("disabled")
        }
    });


    $("#button-open-4").click(function () {
        $.modal.open('添加用户', "/form", '900', '500', callback);
    })

    function callback(index, layero) {
        alert("进入了回调函数提交方法");
        $.ajax({
            url: "/nc/sysNc/insertspkfk",
            type: 'POST',
            data: $("#form-user-add form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加商品成功！！！");
                }
            }
        });
    }

    function getIdSelections() {
        return $.map($('#bootstrap-table').bootstrapTable('getSelections'), function (row) {
            return row.id
        })
    }

    function getsbbhSelections() {
        return $.map($('#bootstrap-table').bootstrapTable('getSelections'), function (row) {
            return row.sbbh
        })
    }

    //多个删除
    function remove() {
        var ids = getIdSelections();
        var wents = getwentSelections();
        if (confirm("确认删除【" + wents + "】吗？？？")) {
            $.ajax({
                url: "/nc/sysNc/deleteallspkfk/" + ids,
                type: 'DELETE',
                success: function (result) {
                    if (result != null) {
                        alert("删除成功！！！");
                        window.location.href = window.location.href;
                    }
                },
            });
        }
    }

    function responseHandler(res) {

        $.each(res.rows, function (i, row) {
            row.state = $.inArray(row.id, selections) !== -1
        })
        return res
    }

    function queryParams(params) {
        var param = {
            limit: params.limit, // 页面大小
            offset: params.offset, // 页码
            nextPage: params.pageNumber,
            pageNumber: params.pageNumber,
            pageSize: params.pageSize,
            // sbbh: $("#sbbh").val(),
        };
        return param;
    }

    function detailFormatter(index, row) {
        var html = []
        $.each(row, function (key, value) {
            html.push('<p><b>' + key + ':</b> ' + value + '</p>')
        })
        return html.join('')
    }

    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width: 100,
        height: 100
    });

    //打印设备台账开始
    function Mysbtz() {
        var options = $('#divid_sbtz').html();
        LODOP = getLodop();
        LODOP.PRINT_INIT("");
        LODOP.ADD_PRINT_TABLE(5, 5, 2970, 2100, options);
        LODOP.PREVIEW();
    };
    //打印设备台账结束
    //生成二维码js开始
    function EditViewById(row, index) {
        //$('.edittosummernote').summernote('destroy');
        var data = JSON.stringify($("#bootstrap-table").bootstrapTable('getData')); //获取全部数据
        var data_json = JSON.parse(data); //data_json和data_json2一样都是json对象
        var data_json2 = eval("(" + data + ")");
        $('#text').val('https://192.168.10.188:9090/nc/sbxxb/sbwh/' + data_json[index].sbbh + '/');
        // //由于data2已经是对象了，alert不能显示对象只能显示为[object Object],需要控制台打印
        // //根据index找到对应行数据，填充数据到修改模态框
        // $("#id_update_static_15").val(data_json[index].id);
        // $("#mkmc_update_input_15").val(data_json[index].mkmc);
        // $("#went_update_input_15").val(data_json[index].went);
        // $("#yuany_update_input_15").val(data_json[index].yuany);
        // // $("#jjbz_update_input_15").val(data_json[index].jjbz);
        //
        // $('.edittosummernote').html($(".edittosummernote").val(data_json[index].jjbz).val());
        // $('.edittosummernote').summernote({focus: true});
        // $("#emp_update_btn").val(data_json[index].id);
        // //弹出修改模态框，非新增模态框
        // $('#myModal5').modal('show')

        // $('.edittosummernote').html($('#text').val('http://localhost:9090/nc/sbxxb/sbxx/' + data_json[index].sbbh));
        // $('.edittosummernote').summernote({好，那我们来我看下啊，55 15 15。那我想问一下。是？
        //     callbacks: {
        //         onInit: function () {
        //             var elText = document.getElementById("text");
        //             qrcode.makeCode(elText.value);
        //             // alert(window.screenY);
        //         }
        //     }
        // });

        $("#emp_save_btn").val(data_json[index].sbbh);
        makecode();
        $('#empAddModal').modal('show');
    }

    function makecode() {
        var elText = document.getElementById("text");
        qrcode.makeCode(elText.value);
        // alert(document.getElementById("qrcode").lastElementChild.outerHTML);
    }

    //生成二维码js结束
    function updatespkfk(obj) {
        var sbbh = obj.getAttribute("value");
        var qrcode = document.getElementById("qrcode").lastElementChild.outerHTML;
        $("#qrcode_update_input_15").val(qrcode);
        $.ajax({
            url: "/nc/sbxxb/editspkfk/" + sbbh,
            type: 'PUT',
            data: $("#empAddModal form").serialize(),
            success: function (result) {
                if (result != null) {
                    $("#empAddModal").modal('hide');
                    window.location.href = window.location.href;
                }
            }
        });
    };

    //打印设备标签二维码开始
    function MyPreview() {
        var column = $('#bootstrap-table').bootstrapTable('getSelections');
        var options = "";
        LODOP = getLodop();
        LODOP.PRINT_INIT("");
        var iCurLine = 20;
        for (var i = 0; i < column.length; i++) {  //遍历json数组
            options = "<table class='table table-hover table-bordered' cellpadding='0' border='1' cellspacing='0'>"
                + "<tr><td colspan='2'><div align='center' style='font-family: 微软雅黑;font-size: 12pt'>安徽海王国安医药有限公司</div></td><td rowspan='4'>" + column[i].qrcode + "</td></tr>"
                + "<tr><td colspan='2'><div align='center' style='font-size: 12pt;font-family: 微软雅黑'>固定资产管理标签</div></td></tr>"
                + "<tr><td style='width:90px'><div align='center' style='font-family: 微软雅黑;font-size: 12pt'>资产编号</div></td><td style='width: 160px'><div align='center'><strong style='font-size: 14pt;font-family: 微软雅黑'>" + column[i].sbbh + "</strong></div></td></tr>"
                + "<tr><td style='width:90px'><div align='center' style='font-size: 12pt;font-family: 微软雅黑'>资产名称</div></td><td style='width: 160px'><div align='center'><strong style='font-family: 微软雅黑;font-size: 14pt'>" + column[i].sbmc + "</strong></div></td></tr>"
                + "</table>";
            if (i % 2 == 1) {
                LODOP.ADD_PRINT_TABLE(iCurLine, 400, 380, 20, options);
                iCurLine += 130;
            } else {
                LODOP.ADD_PRINT_TABLE(iCurLine, 20, 380, 20, options);
            }
        }
        // $('#divid').append(options);
        LODOP.PREVIEW();
    };

    //打印设备标签二维码开始
    function gettjmtk() {
        $("#sbAddModal").modal({
            backdrop: "static"
        });
        getDepts("#sbAddModal select");
    };
    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#gmrq_id',
                type: 'date'
            });
        });
    });

    function getDepts(ele) {
        $.ajax({
            url: "/nc/bmxxb/getbmxx/",
            type: 'get',
            success: function (data) {
                $('#bmid_id').empty();
                var options = "";   //字符串拼接
                $("#bmid_id").append('<option value="">请选择部门</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].id + "'>" + data[i].bmmc + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#bmid_id').append(options);
            },
        });
    };

    $('#sbmc_sel').change(function () {
        $('#tbody_id').empty();
        var sbmc = $('#sbmc_sel option:selected').val()
        $.ajax({
            url: "/nc/sbxxb/getsbwh/" + sbmc,
            type: 'GET',
            success: function (data) {
                var tables = "";   //字符串拼接
                var j = 0;
                for (var i in data) {  //遍历json数组
                    j = parseInt(i) + 1;
                    tables = "<tr style='font-family: 微软雅黑;font-size: 9pt;height: 30px'>"
                        + "<td align='center'>" + j + "</td>"
                        + "<td align='center'>" + data[i].sbbh + "</td>"
                        + "<td align='center'>" + data[i].sbmc + "</td>"
                        + "<td align='center'>" + data[i].zbxh + "</td>"
                        + "<td align='center'>" + data[i].cpuxh + "</td>"
                        + "<td align='center'>" + data[i].ncggdx + "</td>"
                        + "<td align='center'>" + data[i].ypdx + "</td>"
                        + "<td align='center'>" + data[i].xsqppcc + "</td>"
                        + "<td align='center'>" + data[i].dw + "</td>"
                        + "<td align='center'>" + data[i].shul + "</td>"
                        + "<td align='center'>" + data[i].shccj + "</td>"
                        + "<td align='center'>" + data[i].gmrq + "</td>"
                        + "<td align='center'>" + data[i].ipdz + "</td>"
                        + "<td align='center'>" + data[i].macdz + "</td>"
                        + "<td align='center'>" + data[i].beiz + "</td>"
                        + "<td align='center'>" + data[i].bmid + "</td>"
                        + "<td align='center'>" + data[i].shiyr + "</td>"
                        + "</tr>";
                    $('#tableid_sbtz').append(tables);
                }
            }
        })
    });

    $('#bmid_id').change(function () {
        var bmid = $("#bmid_id option:selected").val();
        $('#shiyr_id').val("");
        $('#browsers').empty();
        $.ajax({
            url: "/nc/ygxxb/getygxx/" + bmid,
            type: 'get',
            success: function (data) {
                $('#shiyr_id').empty();
                var options = "";   //字符串拼接
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].xingm + "'>" + data[i].zjm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#browsers').append(options);
            },
        });
    });

    function savesb() {
        var ypdx_sel_1 = $("#ypdx_sel_1 option:selected").text();
        var ypdx_sel_2 = $("#ypdx_sel_2 option:selected").text();
        var ypdx_sel_3 = $("#ypdx_sel_3 option:selected").text();
        var sbbh_id = $("#sbbh_id").val()
        var sbmc_id = $("#sbmc_id").val()
        var guige_id = $("#guige_id").val()
        var shccj_id = $("#shccj_id").val()
        var gmrq_id = $("#gmrq_id").val()
        var bmid_id = $("#bmid_id").val()
        var shiyr_id = $("#shiyr_id").val()
        var zbxh_id = $('#zbxh_id').val()
        var cpuxh_id = $('#cpuxh_id').val()
        var ncggdx_id = $('#ncggdx_id').val()
        var ypdx_id_1 = $('#ypdx_id_1').val()
        var ypdx_id_2 = $('#ypdx_id_2').val()
        var ypdx_id_3 = $('#ypdx_id_3').val()
        var xsqppcc_id = $('#xsqppcc_id').val()
        var ipdz_id = $('#ipdz_id').val()
        var macdz_id = $('#macdz_id').val();
        var index = ypdx_id_1.lastIndexOf("\-");
        var ypdx_id_shuzi_1 = ypdx_id_1.substring(index + 1, ypdx_id_1.length);
        var index = ypdx_id_2.lastIndexOf("\-");
        var ypdx_id_shuzi_2 = ypdx_id_2.substring(index + 1, ypdx_id_2.length);
        var index = ypdx_id_3.lastIndexOf("\-");
        var ypdx_id_shuzi_3 = ypdx_id_3.substring(index + 1, ypdx_id_3.length);
        if (sbmc_id == "") {
            alert("请先选择设备类型后，点击生成设备编号按钮，谢谢您的合作！！！")
        } else if (sbbh_id == "") {
            alert("设备编号是自动生成的，点击生成设备编号按钮")
            // } else if (guige_id == "") {
            //     alert("请输入品牌型号")
            //     $("#guige_id").focus()
        } else if (shccj_id == "") {
            alert("请输入生产厂家")
            $("#shccj_id").focus()
        } else if (gmrq_id == "") {
            alert("请选择购买日期")
            $("#gmrq_id").focus()
        } else if (bmid_id == "") {
            alert("请点击选择部门的下拉框")
            $("#bmid_id").focus()
        } else if (shiyr_id == "") {
            alert("请输入姓名的助记码，助记码为拼音首字母")
            $("#shiyr_id").focus()
        } else if (zbxh_id == "" && sbmc_id.indexOf("电脑") > 0) {
            alert("请输入主板型号")
            $("#zbxh_id").focus()
        } else if (cpuxh_id == "" && sbmc_id.indexOf("电脑") > 0) {
            alert("请输入CPU型号")
            $("#cpuxh_id").focus()
        } else if (ncggdx_id == "" && sbmc_id.indexOf("电脑") > 0) {
            alert("请输入内存大小")
            $("#ncggdx_id").focus()
        } else if (ypdx_id_1 == "" && sbmc_id.indexOf("电脑") > 0) {
            alert("请输入硬盘大小")
            $("#ypdx_id_1").focus()
        } else if (xsqppcc_id == "" && sbmc_id.indexOf("电脑") > 0) {
            alert("请输入显示器大小")
            $("#xsqppcc_id").focus()
            // }else if(ipdz_id==""&&sbmc_id.indexOf("电脑")>0){
            //     alert("请输入IP地址")
            //     $("#ipdz_id").focus()
            // }else if(macdz_id==""&&sbmc_id.indexOf("电脑")>0){
            //     alert("请输入MAC物理地址")
            //     $("#macdz_id").focus()
        } else if (zbxh_id == "" && sbmc_id.indexOf("务器") > 0) {
            alert("请输入主板型号")
            $("#zbxh_id").focus()
        } else if (cpuxh_id == "" && sbmc_id.indexOf("务器") > 0) {
            alert("请输入CPU型号")
            $("#cpuxh_id").focus()
        } else if (ncggdx_id == "" && sbmc_id.indexOf("务器") > 0) {
            alert("请输入内存大小")
            $("#ncggdx_id").focus()
        } else if (ypdx_id_1 == "" && sbmc_id.indexOf("务器") > 0) {
            alert("请输入硬盘大小")
            $("#ypdx_id_1").focus()
        } else if (xsqppcc_id == "" && sbmc_id.indexOf("务器") > 0) {
            alert("请输入显示器大小")
            $("#xsqppcc_id").focus()
            // }else if(ipdz_id==""&&sbmc_id.indexOf("务器")>0){
            //     alert("请输入IP地址")
            //     $("#ipdz_id").focus()
            // }else if(macdz_id==""&&sbmc_id.indexOf("务器")>0){
            //     alert("请输入MAC物理地址")
            //     $("#macdz_id").focus()
        } else if (ypdx_id_shuzi_1 >= 50 && ypdx_sel_1 == "T") {
            alert("硬盘1大小以T为单位，请输入的硬盘大小不能大于50T")
            $("#ypdx_id_1").val("");
        } else if (ypdx_id_shuzi_1 <= 80 && ypdx_sel_1 == "G") {
            alert("硬盘1大小以G为单位，请输入的硬盘大小必须大于80G")
            $("#ypdx_id_1").val("");
        } else if (ypdx_id_shuzi_2 >= 50 && ypdx_sel_2 == "T") {
            alert("硬盘2大小以T为单位，请输入的硬盘大小不能大于50T")
            $("#ypdx_id_2").val("");
        } else if (ypdx_id_shuzi_2 <= 80 && ypdx_sel_2 == "G") {
            alert("硬盘2大小以G为单位，请输入的硬盘大小必须大于80G")
            $("#ypdx_id_2").val("");
        } else if (ypdx_id_shuzi_3 >= 50 && ypdx_sel_3 == "T") {
            alert("硬盘3大小以T为单位，请输入的硬盘大小不能大于50T")
            $("#ypdx_id_3").val("");
        } else if (ypdx_id_shuzi_3 <= 80 && ypdx_sel_3 == "G") {
            alert("硬盘3大小以G为单位，请输入的硬盘大小必须大于80G")
            $("#ypdx_id_3").val("");
        } else {
            savesbforajax()
        }
    }

    function savesbforajax() {
        $.ajax({
            url: "/nc/sbxxb/insertsb",
            type: 'POST',
            data: $("#sbAddModal form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加成功！！！");
                    $("#sbAddModal").modal('hide');
                    window.location.href = window.location.href;
                }
            }
        });
    }

    // $('#ypdx_id_1').bind('focus',function(){
    //     $.modal.open('添加用户', "/ypdx", '500', '300',callback);
    // })

    var jxyp = "机械-";
    var gtyp = "固态-";
    $('#ypdx_btn_1').click(function () {
        $('#sbAddModal').modal('toggle');
        $.confirm({
            title: '硬盘一信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<input type="text" placeholder="请输入硬盘大小，注意单位" class="name form-control"/>' +
                '<select class="ypdx form-control"><option value="T">T</option><option value="G">G</option> </select>' +
                '</div>' +
                '</form>',
            buttons: {
                jxypformSubmit: {
                    text: '机械硬盘',
                    btnClass: 'btn-blue',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('硬盘空间大小不能为空');
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G');
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T');
                            return false;
                        }
                        $("#ypdx_id_1").val(jxyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },

                gtypformSubmit: {
                    text: '固态硬盘',
                    btnClass: 'btn-green',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('provide a valid name');
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G');
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T');
                            return false;
                        }
                        $("#ypdx_id_1").val(gtyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            },
        });
    });
    // $('#ypdx_id_1').bind('blur',function(){
    // $.ajax({
    //     url:"/nc/sbxxb/index",
    //     type:"get",
    //     data:{"op":[[${op}]]},
    //     success:function (data) {
    //         console.log(data)
    //         if($(this).val().length!=0){
    //             $(this).val($(this).val()+op)//添加字符
    //         }
    //     }
    // })
    // var op=[[${op}]];
    // alert(op);
    // var op=[[${yplxmc}]]
    // var url= window.location.search;


    //未用jquery-confirm
    // var jxyp="机械硬盘";
    // var gtyp="固态硬盘";
    //
    // if ($("#ypdx_id_1").val().length!=0) {
    //     var msg=confirm("是机械硬盘按确定，固态硬盘按取消")
    //     if (msg) {
    //         $('#ypdx_id_2').removeAttr("readOnly")
    //         $(this).val(jxyp+$(this).val());
    //     }else {
    //         $('#ypdx_id_2').removeAttr("readOnly")
    //         $(this).val(gtyp+$(this).val());
    //     }
    //
    // }else {
    //     $("#ypdx_id_1").focus();
    // }


    // if($("#ypdx_id_1").val().length<4&&$("#ypdx_id_1").val().length!=0){

    //     }else if($("#ypdx_id_1").val().length>=4){
    //         $("#ypdx_sel_1").focus();
    //     }else {
    //         $("#ypdx_id_1").focus();
    //     }
    // })

    $('#ypdx_btn_2').click(function () {
        $('#sbAddModal').modal('toggle');
        $.confirm({
            title: '硬盘一信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<input type="text" placeholder="请输入硬盘大小，注意单位" class="name form-control"/>' +
                '<select class="ypdx form-control"><option value="T">T</option><option value="G">G</option> </select>' +
                '</div>' +
                '</form>',
            buttons: {
                jxypformSubmit: {
                    text: '机械硬盘',
                    btnClass: 'btn-blue',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('硬盘空间大小不能为空');
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G');
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T');
                            return false;
                        }
                        $("#ypdx_id_2").val(jxyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },

                gtypformSubmit: {
                    text: '固态硬盘',
                    btnClass: 'btn-green',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('provide a valid name');
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G');
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T');
                            return false;
                        }
                        $("#ypdx_id_2").val(gtyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            },
        });
    });

    $('#ypdx_btn_3').click(function () {
        $('#sbAddModal').modal('toggle');
        $.confirm({
            title: '硬盘一信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<input type="text" placeholder="请输入硬盘大小，注意单位" class="name form-control"/>' +
                '<select class="ypdx form-control"><option value="T">T</option><option value="G">G</option> </select>' +
                '</div>' +
                '</form>',
            buttons: {
                jxypformSubmit: {
                    text: '机械硬盘',
                    btnClass: 'btn-blue',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('硬盘空间大小不能为空');
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G');
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T');
                            return false;
                        }
                        $("#ypdx_id_3").val(jxyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },

                gtypformSubmit: {
                    text: '固态硬盘',
                    btnClass: 'btn-green',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('provide a valid name');
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G');
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T');
                            return false;
                        }
                        $("#ypdx_id_3").val(gtyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            }
        });
    });


    function callback(index, layero) {
        alert("进入回调函数了")
        $.modal.closeAll()
    }

    function sbypdx() {
        $.modal.open('添加用户', "/demo/modal/ypdx", '500', '300', callback);
    }

    /**
     * 当ip和Mac有初始值时，将其拆开，显示在每一个文本框中
     * */
        // Mac
    var macShow = "";
    var resultMac = macShow.split(":");
    $("#macdz_id>.mac1").val(resultMac[0]);
    $("#macdz_id>.mac2").val(resultMac[1]);
    $("#macdz_id>.mac3").val(resultMac[2]);
    $("#macdz_id>.mac4").val(resultMac[3]);
    $("#macdz_id>.mac5").val(resultMac[4]);
    $("#macdz_id>.mac6").val(resultMac[5]);
    // ip
    var ipShow = "";
    var resultIp = ipShow.split(".");
    $("#ipdz_id>.ip1").val(resultIp[0]);
    $("#ipdz_id>.ip2").val(resultIp[1]);
    $("#ipdz_id>.ip3").val(resultIp[2]);
    $("#ipdz_id>.ip4").val(resultIp[3]);

    /**
     * mac发生变化时调用即可
     * 将每一个小格中的值获取到传给后台
     * 如果小格中没有值则传空值，有值则传value值，并在后面加上：封号，最后一个不用加
     * */
    function macc() {
        var mac1, mac2, mac3, mac4, mac5, mac6;
        if ($("#macdz_id>.mac1").val() == '') {
            mac1 = '';
        } else {
            mac1 = $("#macdz_id>.mac1").val() + '-';
        }
        if ($("#macdz_id>.mac2").val() == '') {
            mac2 = '';
        } else {
            mac2 = $("#macdz_id>.mac2").val() + '-';
        }
        if ($("#macdz_id>.mac3").val() == '') {
            mac3 = '';
        } else {
            mac3 = $("#macdz_id>.mac3").val() + '-';
        }

        if ($("#macdz_id>.mac4").val() == '') {
            mac4 = '';
        } else {
            mac4 = $("#macdz_id>.mac4").val() + '-';
        }
        if ($("#macdz_id>.mac5").val() == '') {
            mac5 = '';
        } else {
            mac5 = $("#macdz_id>.mac5").val() + '-';
        }
        if ($("#macdz_id>.mac6").val() == '') {
            mac6 = '';
        } else {
            mac6 = $("#macdz_id>.mac6").val();
        }
        var macc = mac1 + mac2 + mac3 + mac4 + mac5 + mac6;
        $("#mac").val(macc);
    }

    /**
     * ip发生变化时调用即可
     * 同Mac一样
     * */
    function ipp() {
        var ip1, ip2, ip3, ip4;
        if ($("#ipdz_id>.ip1").val() == '') {
            ip1 = '';
        } else {
            ip1 = $("#ipdz_id>.ip1").val() + '.';
        }
        if ($("#ipdz_id>.ip2").val() == '') {
            ip2 = '';
        } else {
            ip2 = $("#ipdz_id>.ip2").val() + '.';
        }
        if ($("#ipdz_id>.ip3").val() == '') {
            ip3 = '';
        } else {
            ip3 = $("#ipdz_id>.ip3").val() + '.';
        }
        if ($("#ipdz_id>.ip4").val() == '') {
            ip4 = '';
        } else {
            ip4 = $("#ipdz_id>.ip4").val();
        }
        var ipp = ip1 + ip2 + ip3 + ip4;
        $("#ip").val(ipp);
    }

    /**
     * mac地址格式
     * 键盘按方向键上下左右，光标在四个input中来回切换
     */
    $('#macdz_id>input').each(function (i, o) {
        $(this).attr('cust_index', i);
    })

    $('#macdz_id>input').keydown(function (event) {
        var keycode = event.which;
        //从最后一个小格开始删除，删完之后直接跳到前一个小格中继续删除
        if (event.keyCode == 8 && $(this).val().length == 0) {
            $(this).prev().focus();
        }
        if (38 != keycode && 40 != keycode && 37 != keycode && 39 != keycode) {
            return;
        }
        var ti = $(this).attr('cust_index');
        if (39 == keycode || 40 == keycode) {
            //down
            ti++;
        } else {
            //up
            ti--;
        }
        if (ti < 0) {
            ti = 0;
        }
        var next_obj = $('#macdz_id>input[cust_index=' + ti + ']');
        if (next_obj) {
            next_obj.focus();
        }
    })

    /**
     * 限制mac输入，以及跳下一格的条件
     * */
    $('#macdz_id>input').bind('input propertychange', function () {
        //限制mac只能输入数字母
        var c = $(this);
        //截取输入的最后一个字符
        var lastStr = c.val().substr(c.val().trim().length - 1, 1);
        if (/[^\w]/.test(c.val())) {
            //替换非字母和数字字符，当输入不是字母或数字的时候用空替换
            var temp_amount = c.val().replace(/[^\w]/g, '');
            $(this).val(temp_amount);
            // 当前小格输入的最后一个字符是.并且长度不等于空
            if (/[-]/.test(lastStr) && $(this).val() != '') {
                $(this).next().focus();
            }
        }
        //当前小格输入长度为2时自动跳到下一格
        if ($(this).val().trim().length == 2) {
            $(this).next().focus();
        }
    })

    $('#macdz_id>input').bind('blur', function () {
        if ($(this).val().trim().length < 2) {
            $(this).focus();
            return false;
        }
        macc();
    })

    $('#macdz_id>.mac6').bind('blur', function () {
        if ($("#macdz_id>.mac6").val().trim().length < 2) {
            $("#macdz_id>.mac6").focus();
            return false;
        }
        macc();
    })

    /**
     * 限制ip输入，以及跳下一格的条件
     * */
    $('#ipdz_id>input').bind('input propertychange', function () {
        // 输入不是数字的时候清空
        var c = $(this);
        //截取输入的最后一个字符
        var lastStr = c.val().substr(c.val().trim().length - 1, 1);
        if (/[^\d]/.test(c.val())) {
            //替换非数字字符
            var temp_amount = c.val().replace(/[^\d]/g, '');
            $(this).val(temp_amount);
            // 当前小格输入的最后一个字符是.并且长度不等于空
            if (/[.]/.test(lastStr) && $(this).val() != '') {
                $(this).next().focus();
            }
        }
        // 第二，三，四位输入不在0-255之间的时候清空
        if ($(this).val() < 0 || $(this).val() > 255) {
            $(this).val('');
        }
        //第一位输入不在1-223之间的时候清空
        if ($("#ipdz_id>.ip1").val() < 1 || $("#ipdz_id>.ip1").val() > 223) {
            $("#ipdz_id>.ip1").val('');
        }
        //当每一小格输入的长度等于3时，自动跳到下一个
        if ($(this).val().trim().length == 3) {
            $(this).next().focus();
        }
        ipp();
    })

    /**
     * ip地址格式
     * 键盘按方向键上下左右，光标在四个input中来回切换
     */
    $('#ipdz_id>input').each(function (i, o) {
        $(this).attr('cust_index', i);
    })
    $('#ipdz_id>input').keydown(function (event) {
        var keycode = event.which;
        //从最后一个小格开始删除，删完之后直接跳到前一个小格中继续删除
        if (event.keyCode == 8 && $(this).val().length == 0) {
            $(this).prev().focus();
        }
        if (38 != keycode && 40 != keycode && 37 != keycode && 39 != keycode) {
            return;
        }
        var ti = $(this).attr('cust_index');
        if (39 == keycode || 40 == keycode) {
            //down
            ti++;
        } else {
            //up
            ti--;
        }
        if (ti < 0) {
            ti = 0;
        }
        var next_obj = $('#ipdz_id>input[cust_index=' + ti + ']');
        if (next_obj) {
            next_obj.focus();
        }
    })
    // let sbhb_sel_index=""
    // $('#sbbh_sel').click(function () {
    //     sbhb_sel_index = document.getElementById("sbbh_sel").selectedIndex;
    // })


    // $(function () {
    //     var mysel = $("#sbbh_sel");
    //     // var mysel = document.getElementById("sbbh_sel");
    //     mysel.data("last", mysel.val()).change(function () {
    //         var oldvalue = mysel.data("last").; //这次改变之前的值
    //         mysel.data("last", mysel.val()); //每次改变都附加上去，以便下次变化时获取 改变之前获取并保存
    //         var newvalue = mysel.val(); //当前选中值
    //         alert("改变前的值："+oldvalue+",改变后的值："+newvalue);
    //     });
    // });


    $('#sbbh_sel').change(function () {
        var sel = document.getElementById("sbbh_sel")
        var sbmc_sel_xg = $("#sbbh_sel option:selected").text();
        var sbmc_sel_val = $("#sbbh_sel option:selected").val();
        var sbmc_sel_index = sel.selectedIndex + 1
        // sbmc_index
        // var sbmc_sel_xinz = $("#sbbh_sel option:selected").val();
        $.confirm({
            title: '提示!',
            content: '您确定修改设备类型吗？确定请按确定，否则按取消',
            buttons: {
                confirm: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        $("#ypdx_id_1").val("");
                        $("#ypdx_id_2").val("");
                        $("#ypdx_id_3").val("");
                        $("#sbbh_id").val("")
                        $("#sbmc_id").val(sbmc_sel_xg)
                        $("#sbmc_option").val(sbmc_sel_val)
                        $("#sbmc_index").val(sbmc_sel_index)
                        $("#guige_id").val("")
                        $("#shccj_id").val("")
                        $("#gmrq_id").val("")
                        $("#bmid_id").val("")
                        $("#shiyr_id").val("")
                        $('#zbxh_id').val("")
                        $('#cpuxh_id').val("")
                        $('#ncggdx_id').val("")
                        $('#ypdx_id_1').val("")
                        $('#ypdx_id_2').val("")
                        $('#ypdx_id_3').val("")
                        $('#xsqppcc_id').val("")
                        $("#macdz_id>.mac1").val("")
                        $("#macdz_id>.mac2").val("")
                        $("#macdz_id>.mac3").val("")
                        $("#macdz_id>.mac4").val("")
                        $("#macdz_id>.mac5").val("")
                        $("#macdz_id>.mac6").val("")
                        $("#beiz_id").val("")
                        $("#ipdz_id>.ip1").val("")
                        $("#ipdz_id>.ip2").val("")
                        $("#ipdz_id>.ip3").val("")
                        $("#ipdz_id>.ip4").val("")
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        // console.log($("#sbbh_sel").val(sb));
                        // alert(sbhb_sel_index)
                        // document.getElementById("sbbh_sel").options[sbhb_sel_index].selected = true;
                        // var sbmc_xin = $("#sbmc_id").val()
                        var sbmc_xin_option = $("#sbmc_option").val()
                        // var sbmc_sel_index = $("#sbmc_index").val()
                        // $("#sbbh_sel").prepend("<option value='" + sbmc_xin_option + "' selected>" + sbmc_xin + "</option>");
                        // $("#sbbh_sel option[text='"+sbmc_xin+"']").remove();  //删除Select中Text='4'的Option
                        // $("#sbbh_sel option[index='0']").remove();
                        // $("#sbbh_sel option[value='sbmc_xin']").remove();
                        // $("#sbbh_sel option[index='0']").remove();
                        // var sel = document.getElementById("sbbh_sel");
                        // sel.options.remove(sel.options[0]);//删除第一个下拉框选项
                        // 删除下标的option项
                        // sel.options.remove(sbmc_sel_index)
                        // alert(sel)
                        // alert(sel.value)
                        sel.value=sbmc_xin_option;
                    },
                }
            }
        });
    })

</script>
</body>
</html>